﻿namespace Sidvall.CodeGenerator
{
	public class TypeMappingCollection : System.Collections.ObjectModel.KeyedCollection<string, TypeMapping>
	{
		#region Business Members

		public void Add(string typeName, string newTypeName, string valueFormat, string valueFormatInDataStore)
		{
			TypeMapping item;

			item = new TypeMapping()
			{
				TypeName = typeName,
				NewTypeName = newTypeName,
				ValueFormat = valueFormat,
				ValueFormatInDataStore = valueFormatInDataStore
			};
			Add(item);
		}
		public TypeMapping GetItem(string typeName)
		{
			if (Contains(typeName))
				return this[typeName];
			else
				return null;
		}
		protected override string GetKeyForItem(TypeMapping item)
		{
			if (item == null)
				throw new System.ArgumentNullException("item");
			return item.TypeName;
		}

		#endregion
		#region Constructors

		public TypeMappingCollection()
			: base(System.StringComparer.OrdinalIgnoreCase)
		{
		}

		#endregion
	}
}
